package com.dy.course.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.dy.course.common.BaseController;
import com.dy.course.common.ResponseMessage;
import com.dy.course.entity.MeetingBean;
import com.dy.course.entity.MeetingCreate;
import com.dy.course.entity.MeetingSignInfo;
import com.dy.course.entity.MeetingUserSeat;
import com.dy.course.service.IMeetingService;
import com.github.pagehelper.PageInfo;

@Controller
public class MeetingController extends BaseController {
	
	@Autowired
	private IMeetingService meetingService;

	/**
	 * 会议创建接口
	 * 
	 * @param mc
	 * @return
	 */
	@RequestMapping(value = "/meeting/create", method = RequestMethod.POST)
	@ResponseBody
	public ResponseMessage<?> crateMeeting(@RequestBody MeetingCreate mc) {
		logger.info("【创建会议接口】,参数:mc=" + JSON.toJSONString(mc));
		meetingService.meetingCreate(mc);
		return constructNullResponse();
	}

	/**
	 * 会议查询
	 * 
	 * @param mc
	 * @return
	 */
	@RequestMapping(value = "/meeting/select") 
	@ResponseBody
	public ResponseMessage<PageInfo<MeetingBean>> selectMeeting(MeetingBean mb) {
		logger.info("【创建者查询会议接口】,参数:mb=" + JSON.toJSONString(mb));
		List<MeetingBean> lst = meetingService.selectMeeting(mb);
		PageInfo<MeetingBean> page = new PageInfo<MeetingBean>(lst);
		return constructResponse(page);
	}
	
	/**
	 * 会议查询
	 * 
	 * @param mc
	 * @return
	 */
	@RequestMapping(value = "/meeting/select/user") 
	@ResponseBody
	public ResponseMessage<PageInfo<MeetingBean>> selectMeetingForParticipant(MeetingBean mb) {
		logger.info("【与会者查询会议接口】,参数:mb=" + JSON.toJSONString(mb));
		List<MeetingBean> lst = meetingService.selectMeetingForUser(mb);
		PageInfo<MeetingBean> page = new PageInfo<MeetingBean>(lst);
		return constructResponse(page);
	}
	
	/**
	 * 会议签到
	 * @param query
	 * @return
	 */
	@RequestMapping(value="/meeting/sign",method = RequestMethod.POST)
	@ResponseBody
	public ResponseMessage<?> sign(@RequestBody MeetingSignInfo msi){
		logger.info("【会议签到接口】参数信息,msi = "+JSON.toJSONString(msi));
		meetingService.sign(msi);
		return constructNullResponse();
	}
	
	
	
	/**
	 * 删除会议接口
	 * @param query
	 * @return
	 */
	@RequestMapping(value="/meeting/delete",method = RequestMethod.POST)
	@ResponseBody
	public ResponseMessage<?> delet(@RequestBody MeetingBean mb){
		logger.info("【会议删除接口】参数信息,msi = "+JSON.toJSONString(mb));
		meetingService.deletMeeting(mb);
		return constructNullResponse();
	}
	
	/**
	 * 修改会议接口（暂时不用，留作后用）
	 * @param query
	 * @return
	 */
	@RequestMapping(value="/meeting/update",method = RequestMethod.POST)
	@ResponseBody
	public ResponseMessage<?> update(@RequestBody MeetingBean mb){
		logger.info("【会议删除接口】参数信息,msi = "+JSON.toJSONString(mb));
		meetingService.updateMetting(mb);
		return constructNullResponse();
	}
	
	
	/**
	 * 修改会议接口（暂时不用，留作后用）
	 * @param query
	 * @return
	 */
	@RequestMapping(value="/meeting/member")
	@ResponseBody
	public ResponseMessage<List<MeetingUserSeat>> selectSign(MeetingUserSeat mus){
		logger.info("【会议删除接口】参数信息,mus = "+JSON.toJSONString(mus));
		return constructResponse(meetingService.selectSignUser(mus));
	}
}
